/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * insumos_salidas_detalle.java
 *
 * Created on 21/04/2011, 07:39:43 PM
 */

package sie_invdis;

import java.sql.*;
import javax.swing.*;

import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.JTable.*;
import java.awt.*;
import java.util.Date;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.text.*;
/**
 *
 * @author Michelle
 */
public class insumos_salidas_detalle extends javax.swing.JDialog {

    private javax.swing.table.DefaultTableModel jtable_modelo;
    private javax.swing.table.DefaultTableModel jtable_modelo_modificar;
    private javax.swing.table.DefaultTableModel jtable_modelo_catalogoinsu;

    private int buscamp=1;


    private int control_enter=0,controlcombo=0,indexactual=0,yacarguecatalogo=1;
    
    private SimpleDateFormat formateador = new SimpleDateFormat("dd-MM-yyyy");
    private SimpleDateFormat formateadoresta = new SimpleDateFormat("yyyy-MM-dd");
    //se crea intancia de la clase conexion
    bd_conexion x = new bd_conexion() ;
       //se creaa la variable resultset
    ResultSet rs = null;
    /** Creates new form insumos_salidas_detalle */
    public insumos_salidas_detalle(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
public insumos_salidas_detalle(java.awt.Frame parent, boolean modal,String folio) {
        super(parent, modal);
        this.iniciar_modelo_de_tabla();
        this.iniciar_modelo_tabmodificar();
        this.iniciar_modelo_insumos();
        initComponents();

        this.jbtn_guardar.setVisible(false);
        this.jbtn_recepcionar.setVisible(false);
        this.jckbx_surtircompleto.setVisible(false);
        this.carga_datos_encabezado(1,folio);
        this.cargar_datos_detalle(folio);

        jtb_insumos.getColumnModel().getColumn(0).setPreferredWidth(50);//cantidad
        jtb_insumos.getColumnModel().getColumn(1).setPreferredWidth(150);//codigo
        jtb_insumos.getColumnModel().getColumn(2).setPreferredWidth(40);//descripcion.
        jtb_insumos.getColumnModel().getColumn(3).setPreferredWidth(40);//descripcion.
        jtb_insumos.getColumnModel().getColumn(4).setPreferredWidth(30);//descripcion.
        jtb_insumos.getColumnModel().getColumn(5).setPreferredWidth(60);//descripcion.
        jtb_insumos.getColumnModel().getColumn(6).setPreferredWidth(40);//descripcion.
        yacarguecatalogo=0;
        this.jbtn_sustituirarticulo.setVisible(false);
        this.jbtn_cancelacion.setVisible(false);
        if (variables_global.getnivelusu()<3)
            {
            this.jbtn_sustituirarticulo.setVisible(true);
            this.jbtn_cancelacion.setVisible(true);
            }
        controlcombo=0;
        this.setTitle("Salidas Insumos Detalle: Folio "+folio);
    }

private void iniciar_modelo_de_tabla()
    {
        jtable_modelo=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo.addColumn("<html><b>Clave</b></html>");
        jtable_modelo.addColumn("<html><b>Descripcion</b></html>");
        jtable_modelo.addColumn("<html><b>Unidad</b></html>");
        jtable_modelo.addColumn("<html><b>Cantidad</b></html>");
        jtable_modelo.addColumn("<html><b>Surtido</b></html>");
        jtable_modelo.addColumn("<html><b>Observaciones</b></html>");
        jtable_modelo.addColumn("<html><b>Foto</b></html>");
        jtable_modelo.addColumn("<html><b>Tipo</b></html>");
        jtable_modelo.addColumn("<html><b>Precio U.</b></html>");
        jtable_modelo.addColumn("<html><b>Importe</b></html>");
    }
private void iniciar_modelo_tabmodificar()
    {
        jtable_modelo_modificar=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo_modificar.addColumn("<html><b>Clave</b></html>");
        jtable_modelo_modificar.addColumn("<html><b>Descripcion</b></html>");
        jtable_modelo_modificar.addColumn("<html><b>Unidad</b></html>");
        jtable_modelo_modificar.addColumn("<html><b>Cantidad</b></html>");
        jtable_modelo_modificar.addColumn("<html><b>Observaciones</b></html>");
        jtable_modelo_modificar.addColumn("<html><b>Tipo</b></html>");
    }
private void iniciar_modelo_insumos()
    {
        jtable_modelo_catalogoinsu=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo_catalogoinsu.addColumn("<html><b>Status</b></html>");
        jtable_modelo_catalogoinsu.addColumn("<html><b>Tipo Elemento</b></html>");
        jtable_modelo_catalogoinsu.addColumn("<html><b>Clave</b></html>");
        jtable_modelo_catalogoinsu.addColumn("<html><b>Descripcion.</b></html>");
        jtable_modelo_catalogoinsu.addColumn("<html><b>Item.</b></html>");
        jtable_modelo_catalogoinsu.addColumn("<html><b>Un</b></html>");
        jtable_modelo_catalogoinsu.addColumn("<html><b>Precio</b></html>");
        jtable_modelo_catalogoinsu.addColumn("<html><b>Existencia</b></html>");


    }
private void carga_datos_encabezado(int opbus,String tbusca)
    {
        String fechacat = "",fechallegatienda="",fechaentrega="";
         DecimalFormat miformat = new DecimalFormat("###,###,###,###");


       //invoco al metodo que trae el recordset de datos
       rs = x.sieuno_executediversosv2("select * from x1distribucion_insumos_salidas_catalogov2('"+variables_global.getcliente_tistribucion()+"',"+opbus+",'"+tbusca+"',"+Integer.valueOf(variables_global.getdepartamento())+") as (idreg integer,iddocto character varying(12),idesta smallint,desta character varying(15), claveperdoc character varying(16), doc_anterior character varying(12),doc_sig character varying(12),fedoc date,feent date,fechaven date,impu numeric, impu2 numeric,desctotal numeric,descfinan numeric,idclie character varying(12),nomclie character varying(60),obserdoc character varying(80),usuario character varying(20),hora text,alma smallint,depa smallint,descripalma character varying(30),descripdepa character varying(30), tpz numeric,totcosto numeric,totprecio numeric,idtipo smallint,idconsiga integer,nombreconsigando text,describetipoinsu character varying(40));",variables_global.getconexiongral());
        try
         {
            while (rs.next())
                {
                    this.jtf_almacen.setText(rs.getString ("descripalma"));
                    this.jcmbx_almacenes.addItem(rs.getString("alma")+":"+rs.getString("descripalma"));
                    this.jtf_folio.setText(rs.getString ("iddocto"));
                    this.jtf_status.setText(rs.getString ("idesta")+":"+rs.getString ("desta"));
                    this.jtf_fecha.setText(this.fechaeuropea(rs.getString ("fedoc"))+":"+DiaSemana(this.fechaeuropea(rs.getString ("fedoc")))+" "+rs.getString ("hora"));

                 if(rs.getString("feent") != null)
                        {
                            this.jtf_fechaenterado.setText(rs.getString("feent")+":"+DiaSemana(rs.getString ("feent")));
                        }

                 if(rs.getString("fechaven") != null )
                        {
                            this.jtf_fecharecibido.setText(rs.getString ("fechaven")+":"+this.DiaSemana(rs.getString("fechaven")));
                        }
                 this.jtf_departamento.setText(rs.getString ("descripdepa"));
                 this.jtf_observaciones.setText(rs.getString ("obserdoc"));

                  if(rs.getInt("idesta")==1)
                     {
                            this.jbtn_guardar.setVisible(true);
                            this.jckbx_surtircompleto.setVisible(true);
                     }
                 if(rs.getInt("idesta")==2)
                     {
                            this.jbtn_recepcionar.setVisible(true);
                     }
                 this.jtf_nombreconsignado.setText(rs.getString("nombreconsigando"));
                 this.jtf_total.setText(miformat.format(rs.getFloat("totprecio")));

                }

        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
}

private void verfotosestereporte()
    {
     int numerofilas=this.jtable_modelo.getRowCount();
        this.cambiartamanofilas();
             for(int i = 0 ;i < numerofilas; i++)
                {
                      jtable_modelo.setValueAt("<html><head></head><body><p style=\"margin-top: 0\"><img src=\"http://"+variables_global.getHost()+"/javaweb/insumos/"+jtable_modelo.getValueAt(i, 0).toString()+".JPG\" width=\"180\" height=\"120\" border=\"0\" alt=\"Foto\"></img></p></body></html>", i,5);
                }

           //
    }
private void quitarfotosestereporte()
    {
     int numerofilas=this.jtable_modelo.getRowCount();
        this.cambiartamanofilaschi();
             for(int i = 0 ;i < numerofilas; i++)
                {
                      jtable_modelo.setValueAt(".", i,6);
                }

           //
    }

private void surtirtodo()
    {
     int numerofilas=this.jtable_modelo.getRowCount();

             for(int i = 0 ;i < numerofilas; i++)
                {
                      jtable_modelo.setValueAt(jtable_modelo.getValueAt(i, 3).toString(), i,4);
                }

           //
    }

void cambiartamanofilas()
    {
     //limpiar la tabla


       int numerofilas=this.jtable_modelo.getRowCount();

             for(int i = 0 ;i < numerofilas; i++)
                {
                     jtb_insumos.setRowHeight(i, 140);
                }
    }
void cambiartamanofilaschi()
    {
     //limpiar la tabla


       int numerofilas=this.jtable_modelo.getRowCount();

             for(int i = 0 ;i < numerofilas; i++)
                {
                     jtb_insumos.setRowHeight(i, 35);
                }
    }

private void cargar_datos_detalle(String docto)
    {
     DecimalFormat miformat = new DecimalFormat("############.###");
       rs = x.sieuno_executediversosv2("select * from x1distribucion_insumos_salidas_detalle('"+docto+"') as (idreg integer,iddocto character varying(12),idarti character varying(16),can_articulo numeric,costo numeric,precio numeric,importe numeric,importecosto numeric,obserparti character varying(80),artidescrip character varying(80),unidadsal character varying(3),descriptipo character varying(40),canrecibida numeric);",variables_global.getconexiongral());
       try
         {
            while (rs.next())
                {
                    jtable_modelo.addRow(new Object[]{rs.getString ("idarti"),rs.getString ("artidescrip"),rs.getString("unidadsal"),rs.getString("can_articulo"),rs.getString("canrecibida"),rs.getString("obserparti"),"",rs.getString("descriptipo"),miformat.format(rs.getFloat("precio")),miformat.format(rs.getFloat("precio")*rs.getFloat("can_articulo"))});
                    jtable_modelo_modificar.addRow(new Object[]{rs.getString ("idarti"),rs.getString ("artidescrip"),rs.getString("unidadsal"),rs.getString("can_articulo"),rs.getString("obserparti"),rs.getString("descriptipo")});
                }
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
    }

private void carga_datos_catalogo_insumos(int opcion, int opbuscamp,String busqueda,int almacen)
 {
       while(jtable_modelo_catalogoinsu.getRowCount()>0)jtable_modelo_catalogoinsu.removeRow(0);
       Object[] fnewRow = new Object[8];
       String texto="select * from x1distribucion_insumos_articulos_catalogo("+opcion+","+opbuscamp+",'"+busqueda.toUpperCase().trim()+"',"+almacen+") as (id character varying(16),cod character varying(16), idstatus smallint, descristatus character varying(40), describinsumo character varying(80), itemprovee character varying(16), unisal character varying(3), unient character varying(3), facentunidad numeric, uniempaque character varying(12), tipoelemento smallint, describetipoelemen character varying(40), idfamilia character varying(5),describefamilia character varying(40),idlineainsu character varying(5), describelineainsu character varying(40), controlalmacen character varying(20), stockminimo numeric, stockmaximo numeric,precio1 numeric, precio2 numeric,ultimocosto numeric, costoprome numeric, fechaulticompra date, fechaultimaventa date, idprovee character varying(16), describeprovee character varying(80), impuesto1 numeric, impuesto2 numeric, usuario character varying(20),valor_x_insumo character varying(20), observacion character varying(255),existenciainsu numeric)";
      
       System.out.println(texto);
       try
        {
            rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
            while (rs.next())
                {
                    fnewRow[0]=rs.getString("descristatus");
                    fnewRow[1]=rs.getString("describetipoelemen");
                    fnewRow[2]=rs.getString("id");
                    fnewRow[3]=rs.getString("describinsumo");
                    fnewRow[4]=rs.getString("itemprovee");
                    fnewRow[5]=rs.getString("unisal");
                    fnewRow[6]=rs.getString("precio1");
                    fnewRow[7]=rs.getString("existenciainsu");
                    jtable_modelo_catalogoinsu.addRow(fnewRow);
                }

        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
 }
private void loadcomalmacenes()
    {
          rs = x.sieuno_executediversosv2("select * from x1distribucion_insumos_almacenes() as (id smallint,cla character varying(30));",variables_global.getconexiongral());
            try
            {
               while (rs.next())
                    {
                      this.jcmbx_almacenes.addItem(rs.getString("id")+":"+rs.getString("cla"));
                    }
             }
            catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
    }
private String  fechaeuropea(String fecha) {
       //resibe cadena de fecha en formato americano yyyy-MM-dd
       java.util.Date fechaestaeuropa=null;
       SimpleDateFormat formateadorestaeuropa = new SimpleDateFormat("dd-MM-yyyy");
       String cadenafecha="";
        try
         {
          fechaestaeuropa = formateadoresta.parse(fecha);
         }
        catch (ParseException e)
          {
             //Error, la cadena de texto no se puede convertir en fecha.
          }
       cadenafecha= formateadorestaeuropa.format(fechaestaeuropa);
       return cadenafecha;
    }
private String DiaSemana(String fe) {
       String dia = "";
       java.util.Date fecha=null;
         try
            {
             fecha = formateador.parse(fe);
           }
        catch (ParseException e)
            {
            //Error, la cadena de texto no se puede convertir en fecha.
            }
        Calendar cal= Calendar.getInstance();
        cal.setTime(fecha);
        //ojo para establecer o recetear cada parte de la fecha por separado
        //cal.set(Calendar.YEAR, fecha.getYear());
        //cal.set(Calendar.MONTH, fecha.getMonth());
        //cal.set(Calendar.DAY_OF_MONTH, fecha.getDay());
        int diaInt = cal.get(Calendar.DAY_OF_WEEK);
        switch (diaInt) {
            case 1:
                dia = "Domingo";
                break;
            case 2:
                dia = "Lunes";
                break;
            case 3:
                dia = "Martes";
                break;
            case 4:
                dia = "Miercoles";
                break;
            case 5:
                dia = "Jueves";
                break;
            case 6:
                dia = "Viernes";
                break;
            case 7:
                dia = "Sabado";
                break;

        }
        return dia;
    }

private void articulo_actualizacodigo(int opcion,String id,String texto1,String texto2)
    {
        String texto="select * from x1distribucion_insumos_salidas_operaciones("+opcion+","+id+",'"+texto1+"','"+texto2+"')";
        try
            {
                rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
                while (rs.next())
                {

                    if (rs.getInt(1) > 0)
                        {
                            JOptionPane.showMessageDialog(null,"Actualizacion Correcta, Gracias", "Sistema Integral(Requisicion Insumos) : Confirmacion",1);
                        }
                    else
                        {
                            JOptionPane.showMessageDialog(null," Error ", "Sistema Integral(requisicion Insumos) : Error",1);
                        }
                }
            }
            catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jtf_departamento = new javax.swing.JTextField();
        jtf_fecha = new javax.swing.JTextField();
        jtf_fechaenterado = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jtf_fecharecibido = new javax.swing.JTextField();
        jtf_observaciones = new javax.swing.JTextField();
        jtf_almacen = new javax.swing.JTextField();
        jtf_folio = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jtf_status = new javax.swing.JTextField();
        jcb_verfotos = new javax.swing.JCheckBox();
        jLabel9 = new javax.swing.JLabel();
        jtf_nombreconsignado = new javax.swing.JTextField();
        jckbx_surtircompleto = new javax.swing.JCheckBox();
        jPanel2 = new javax.swing.JPanel();
        jbtn_recepcionar = new javax.swing.JButton();
        jbtn_salir = new javax.swing.JButton();
        jbtn_helpayudame = new javax.swing.JButton();
        jbtn_imprimir = new javax.swing.JButton();
        jbtn_guardar = new javax.swing.JButton();
        jtf_total = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jpn_cuerpo = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtb_insumos = new javax.swing.JTable()
        {
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                if (mColIndex < 4)
                return false;
                else
                return true;
            }
        }
        ;
        jPanel3 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtb_insumos1 = new javax.swing.JTable()
        {
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                if (mColIndex < 4)
                return false;
                else
                return true;
            }
        }
        ;
        jLabel11 = new javax.swing.JLabel();
        jtf_idarticuloactual = new javax.swing.JTextField();
        jScrollPane3 = new javax.swing.JScrollPane();
        jt_insumos_catalogo = new javax.swing.JTable()
        {
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                return false;
            }
        }
        ;
        jtf_idinsumonuevo = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jbtn_sustituirarticulo = new javax.swing.JButton();
        jbtn_cancelacion = new javax.swing.JButton();
        jcmbx_almacenes = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jmni_imprimi = new javax.swing.JMenuItem();
        jmni_salir = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jmni_escape = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(sie_invdis.Sie_invdisApp.class).getContext().getResourceMap(insumos_salidas_detalle.class);
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel1.border.title"))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jtf_departamento.setEditable(false);
        jtf_departamento.setText(resourceMap.getString("jtf_departamento.text")); // NOI18N
        jtf_departamento.setName("jtf_departamento"); // NOI18N

        jtf_fecha.setEditable(false);
        jtf_fecha.setText(resourceMap.getString("jtf_fecha.text")); // NOI18N
        jtf_fecha.setName("jtf_fecha"); // NOI18N

        jtf_fechaenterado.setEditable(false);
        jtf_fechaenterado.setText(resourceMap.getString("jtf_fechaenterado.text")); // NOI18N
        jtf_fechaenterado.setName("jtf_fechaenterado"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jtf_fecharecibido.setEditable(false);
        jtf_fecharecibido.setText(resourceMap.getString("jtf_fecharecibido.text")); // NOI18N
        jtf_fecharecibido.setName("jtf_fecharecibido"); // NOI18N

        jtf_observaciones.setEditable(false);
        jtf_observaciones.setText(resourceMap.getString("jtf_observaciones.text")); // NOI18N
        jtf_observaciones.setName("jtf_observaciones"); // NOI18N

        jtf_almacen.setEditable(false);
        jtf_almacen.setText(resourceMap.getString("jtf_almacen.text")); // NOI18N
        jtf_almacen.setName("jtf_almacen"); // NOI18N

        jtf_folio.setEditable(false);
        jtf_folio.setText(resourceMap.getString("jtf_folio.text")); // NOI18N
        jtf_folio.setName("jtf_folio"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jtf_status.setEditable(false);
        jtf_status.setText(resourceMap.getString("jtf_status.text")); // NOI18N
        jtf_status.setName("jtf_status"); // NOI18N

        jcb_verfotos.setText(resourceMap.getString("jcb_verfotos.text")); // NOI18N
        jcb_verfotos.setToolTipText(resourceMap.getString("jcb_verfotos.toolTipText")); // NOI18N
        jcb_verfotos.setName("jcb_verfotos"); // NOI18N
        jcb_verfotos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcb_verfotosActionPerformed(evt);
            }
        });

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jtf_nombreconsignado.setEditable(false);
        jtf_nombreconsignado.setName("jtf_nombreconsignado"); // NOI18N

        jckbx_surtircompleto.setText(resourceMap.getString("jckbx_surtircompleto.text")); // NOI18N
        jckbx_surtircompleto.setName("jckbx_surtircompleto"); // NOI18N
        jckbx_surtircompleto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jckbx_surtircompletoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtf_fechaenterado, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jtf_fecharecibido, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtf_nombreconsignado, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtf_status, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtf_folio, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jtf_departamento, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtf_fecha, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jtf_almacen, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4)
                        .addGap(13, 13, 13)
                        .addComponent(jtf_observaciones, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jcb_verfotos)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jckbx_surtircompleto)))
                .addGap(68, 68, 68))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jtf_status, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(jtf_folio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jtf_departamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(jtf_fecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(17, 17, 17)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jtf_fechaenterado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(jtf_fecharecibido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(jtf_nombreconsignado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel4)
                    .addComponent(jtf_almacen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtf_observaciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcb_verfotos)
                    .addComponent(jckbx_surtircompleto))
                .addContainerGap(11, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel2.setName("jPanel2"); // NOI18N

        jbtn_recepcionar.setIcon(resourceMap.getIcon("jbtn_recepcionar.icon")); // NOI18N
        jbtn_recepcionar.setText(resourceMap.getString("jbtn_recepcionar.text")); // NOI18N
        jbtn_recepcionar.setName("jbtn_recepcionar"); // NOI18N
        jbtn_recepcionar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_recepcionarActionPerformed(evt);
            }
        });

        jbtn_salir.setIcon(resourceMap.getIcon("jbtn_salir.icon")); // NOI18N
        jbtn_salir.setText(resourceMap.getString("jbtn_salir.text")); // NOI18N
        jbtn_salir.setName("jbtn_salir"); // NOI18N
        jbtn_salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_salirActionPerformed(evt);
            }
        });

        jbtn_helpayudame.setText(resourceMap.getString("jbtn_helpayudame.text")); // NOI18N
        jbtn_helpayudame.setName("jbtn_helpayudame"); // NOI18N
        jbtn_helpayudame.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_helpayudameActionPerformed(evt);
            }
        });

        jbtn_imprimir.setIcon(resourceMap.getIcon("jbtn_imprimir.icon")); // NOI18N
        jbtn_imprimir.setText(resourceMap.getString("jbtn_imprimir.text")); // NOI18N
        jbtn_imprimir.setName("jbtn_imprimir"); // NOI18N
        jbtn_imprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_imprimirActionPerformed(evt);
            }
        });

        jbtn_guardar.setIcon(resourceMap.getIcon("jbtn_guardar.icon")); // NOI18N
        jbtn_guardar.setText(resourceMap.getString("jbtn_guardar.text")); // NOI18N
        jbtn_guardar.setName("jbtn_guardar"); // NOI18N
        jbtn_guardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_guardarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addComponent(jbtn_guardar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 84, Short.MAX_VALUE)
                .addComponent(jbtn_recepcionar)
                .addGap(57, 57, 57)
                .addComponent(jbtn_imprimir)
                .addGap(65, 65, 65)
                .addComponent(jbtn_salir)
                .addGap(51, 51, 51)
                .addComponent(jbtn_helpayudame)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jbtn_recepcionar)
                .addComponent(jbtn_guardar)
                .addComponent(jbtn_helpayudame)
                .addComponent(jbtn_imprimir)
                .addComponent(jbtn_salir))
        );

        jtf_total.setEditable(false);
        jtf_total.setName("jtf_total"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N
        jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jTabbedPane1StateChanged(evt);
            }
        });

        jpn_cuerpo.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jpn_cuerpo.setName("jpn_cuerpo"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jtb_insumos.setModel(this.jtable_modelo);
        jtb_insumos.setName("jtb_insumos"); // NOI18N
        jScrollPane1.setViewportView(jtb_insumos);

        javax.swing.GroupLayout jpn_cuerpoLayout = new javax.swing.GroupLayout(jpn_cuerpo);
        jpn_cuerpo.setLayout(jpn_cuerpoLayout);
        jpn_cuerpoLayout.setHorizontalGroup(
            jpn_cuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpn_cuerpoLayout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 751, Short.MAX_VALUE)
                .addContainerGap())
        );
        jpn_cuerpoLayout.setVerticalGroup(
            jpn_cuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpn_cuerpoLayout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab(resourceMap.getString("jpn_cuerpo.TabConstraints.tabTitle"), jpn_cuerpo); // NOI18N

        jPanel3.setName("jPanel3"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jtb_insumos1.setModel(this.jtable_modelo_modificar);
        jtb_insumos1.setName("jtb_insumos1"); // NOI18N
        jtb_insumos1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jtb_insumos1MouseClicked(evt);
                if(evt.getClickCount() >= 2)
                {
                    dioclickdet(evt);
                    //System.out.println(" double click" );

                }
            }
        });
        jScrollPane2.setViewportView(jtb_insumos1);

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        jtf_idarticuloactual.setEditable(false);
        jtf_idarticuloactual.setText(resourceMap.getString("jtf_idarticuloactual.text")); // NOI18N
        jtf_idarticuloactual.setName("jtf_idarticuloactual"); // NOI18N

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        jt_insumos_catalogo.setModel(this.jtable_modelo_catalogoinsu);
        jt_insumos_catalogo.setName("jt_insumos_catalogo"); // NOI18N
        jt_insumos_catalogo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jt_insumos_catalogoMouseClicked(evt);
                if(evt.getClickCount() >= 2)
                {
                    dioclick(evt);
                    //System.out.println(" double click" );

                }
            }
        });
        jScrollPane3.setViewportView(jt_insumos_catalogo);

        jtf_idinsumonuevo.setEditable(false);
        jtf_idinsumonuevo.setText(resourceMap.getString("jtf_idinsumonuevo.text")); // NOI18N
        jtf_idinsumonuevo.setName("jtf_idinsumonuevo"); // NOI18N

        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        jbtn_sustituirarticulo.setIcon(resourceMap.getIcon("jbtn_sustituirarticulo.icon")); // NOI18N
        jbtn_sustituirarticulo.setText(resourceMap.getString("jbtn_sustituirarticulo.text")); // NOI18N
        jbtn_sustituirarticulo.setToolTipText(resourceMap.getString("jbtn_sustituirarticulo.toolTipText")); // NOI18N
        jbtn_sustituirarticulo.setName("jbtn_sustituirarticulo"); // NOI18N
        jbtn_sustituirarticulo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_sustituirarticuloActionPerformed(evt);
            }
        });

        jbtn_cancelacion.setIcon(resourceMap.getIcon("jbtn_cancelacion.icon")); // NOI18N
        jbtn_cancelacion.setText(resourceMap.getString("jbtn_cancelacion.text")); // NOI18N
        jbtn_cancelacion.setName("jbtn_cancelacion"); // NOI18N
        jbtn_cancelacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_cancelacionActionPerformed(evt);
            }
        });

        jcmbx_almacenes.setName("jcmbx_almacenes"); // NOI18N
        jcmbx_almacenes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcmbx_almacenesActionPerformed(evt);
            }
        });

        jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
        jLabel13.setName("jLabel13"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 743, Short.MAX_VALUE)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 743, Short.MAX_VALUE)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addGap(12, 12, 12)
                                .addComponent(jtf_idinsumonuevo, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jbtn_sustituirarticulo)
                                .addGap(22, 22, 22)
                                .addComponent(jbtn_cancelacion)))
                        .addContainerGap())
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtf_idarticuloactual, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 253, Short.MAX_VALUE)
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jcmbx_almacenes, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(81, 81, 81))))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jtf_idarticuloactual, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcmbx_almacenes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtf_idinsumonuevo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12)
                    .addComponent(jbtn_sustituirarticulo)
                    .addComponent(jbtn_cancelacion))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel3.TabConstraints.tabTitle"), jPanel3); // NOI18N

        jMenuBar1.setName("jMenuBar1"); // NOI18N

        jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
        jMenu1.setName("jMenu1"); // NOI18N

        jmni_imprimi.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.ALT_MASK));
        jmni_imprimi.setText(resourceMap.getString("jmni_imprimi.text")); // NOI18N
        jmni_imprimi.setName("jmni_imprimi"); // NOI18N
        jmni_imprimi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_imprimiActionPerformed(evt);
            }
        });
        jMenu1.add(jmni_imprimi);

        jmni_salir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
        jmni_salir.setIcon(resourceMap.getIcon("jmni_salir.icon")); // NOI18N
        jmni_salir.setText(resourceMap.getString("jmni_salir.text")); // NOI18N
        jmni_salir.setName("jmni_salir"); // NOI18N
        jmni_salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_salirActionPerformed(evt);
            }
        });
        jMenu1.add(jmni_salir);

        jMenuBar1.add(jMenu1);

        jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
        jMenu2.setName("jMenu2"); // NOI18N

        jmni_escape.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0));
        jmni_escape.setText(resourceMap.getString("jmni_escape.text")); // NOI18N
        jmni_escape.setName("jmni_escape"); // NOI18N
        jmni_escape.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_escapeActionPerformed(evt);
            }
        });
        jMenu2.add(jmni_escape);

        jMenuBar1.add(jMenu2);

        jMenu3.setText(resourceMap.getString("jMenu3.text")); // NOI18N
        jMenu3.setName("jMenu3"); // NOI18N
        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtf_total, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 768, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jtf_total, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(2, 2, 2)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(23, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbtn_recepcionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_recepcionarActionPerformed
        // TODO add your handling code here:
        ResultSet rs = null;
        float cantidad=0,totalarticulos=0;
        int nobjetotabla=this.jtb_insumos.getRowCount();
        int fi=0,controlfolio=0,error=0;

        String cadenafilas="{'", arreglo_articulos[]=null;
        JPasswordField pwd = new JPasswordField(10);
        this.quitarfotosestereporte();
        //lanso la confirmacion de password
        int action = JOptionPane.showConfirmDialog(null, pwd,"Contraseña:(Use Tab p/moverse o Mause)",JOptionPane.OK_CANCEL_OPTION);
        if(action < 0) {
            JOptionPane.showMessageDialog(null,"No se realiza Proceso, Gracias");
        } else {
            //comparo si la contraseña es apropiada
            if(variables_global.getPassword().equals(String.valueOf(pwd.getPassword()))) {//inicia trabajo para actualizar diferencias


                for(fi=0;fi<nobjetotabla;fi++) {

                        try{
                            cantidad = Float.valueOf(this.jtb_insumos.getValueAt(fi, 4).toString()).floatValue();
                            totalarticulos+=cantidad;
                        }catch (NumberFormatException nfe) {
                            cantidad=0;
                            error=1;
                        }
                    // System.out.println("cachar error"+cadenafilas);
                    if (cantidad > 0)
                        {
                            cadenafilas+=""+this.jtb_insumos.getValueAt(fi, 4).toString()+":"+this.jtb_insumos.getValueAt(fi, 0).toString()+":"+this.jtb_insumos.getValueAt(fi, 4)+""+"\n";
                        }



                }//fin del for

                    //System.out.println(s);
                //arreglo_articulos=cadenafilas.split(":");
                if(error==0)
                   {
                        if(JOptionPane.showConfirmDialog(null, "Documento sera Guardado. Estan correcto sus Datos?")==0)
                            {

                             this.quitardescripcion();
                             java.util.Vector arreglodearticulos=this.jtable_modelo.getDataVector();

                            String articulos_papostgresql=arreglodearticulos.toString();
                            articulos_papostgresql=articulos_papostgresql.replace('[','{');
                            articulos_papostgresql=articulos_papostgresql.replace(']','}');
                            articulos_papostgresql=articulos_papostgresql.replace("null",".");

                                String texto="select * from x1distribucion_insumos_salidas_recepcionarv2("+Integer.valueOf(this.jtf_folio.getText().toString())+",'"+articulos_papostgresql+"')";
                                System.out.println(texto);

                                try {
                                    rs=x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
                                    while (rs.next())
                                        {
                                            controlfolio=rs.getInt(1);
                                            if (rs.getInt(1) > 0)
                                                {
                                                    JOptionPane.showMessageDialog(null,"Requisicion Correcta, Gracias", "Sistema Integral(Requisicion Insumos) : Confirmacion",1);
                                                    this.imprimir(1,1,controlfolio);

                                                }
                                            else
                                                {
                                                    JOptionPane.showMessageDialog(null," Error Verifique sus Cantidades", "Sistema Integral(requisicion Insumos) : Error",1);
                                                }
                                        }
                                    } catch(Exception e)
                                       {
                                            System.out.println(e.getMessage());
                                            JOptionPane.showMessageDialog(null," Recepcion Incorrecta ", "Sistema Integral(Requisicion Insumos) : Error",1);
                                       }
                            //this.btn_guardar.setVisible(false);
                        }//fin del if qu confirmo guardar diferencia
                    }//cierra el if si la
                else
                    {
                        JOptionPane.showMessageDialog(null,"por Favor verifique que las cantidadades sean solo numeros Use Observaciones para dar detalle");
                    }

            }//cierra el if del password
            else
                {
                    JOptionPane.showMessageDialog(null,"por Favor teclee su contraseña coreectamente, verifique mayusculas en teclado");
                }

        }

}//GEN-LAST:event_jbtn_recepcionarActionPerformed

    private void jbtn_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_salirActionPerformed
        // TODO add your handling code here:
   if(JOptionPane.showConfirmDialog(null, "Desea Salir?")==0)
            {
                 this.dispose();
            }
}//GEN-LAST:event_jbtn_salirActionPerformed

    private void jbtn_helpayudameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_helpayudameActionPerformed
        // TODO add your handling code here:
        this.ayuda();
}//GEN-LAST:event_jbtn_helpayudameActionPerformed

    private void jmni_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_salirActionPerformed
        // TODO add your handling code here:
        this.jbtn_salirActionPerformed(evt);
    }//GEN-LAST:event_jmni_salirActionPerformed

    private void jcb_verfotosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcb_verfotosActionPerformed
        // TODO add your handling code here:
        if(this.jcb_verfotos.isSelected()==true) {
            this.verfotosestereporte();
        } else {
            this.quitarfotosestereporte();
        }
    }//GEN-LAST:event_jcb_verfotosActionPerformed

    private void jbtn_imprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_imprimirActionPerformed
        // TODO add your handling code here:
         this.imprimir(0,1,Integer.valueOf(this.jtf_folio.getText()));
    }//GEN-LAST:event_jbtn_imprimirActionPerformed

    private void jckbx_surtircompletoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jckbx_surtircompletoActionPerformed
        // TODO add your handling code here:
        if(this.jckbx_surtircompleto.isSelected()==true) {
            this.surtirtodo();
        }
}//GEN-LAST:event_jckbx_surtircompletoActionPerformed

    private void jbtn_guardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_guardarActionPerformed
        // TODO add your handling code here:
        // TODO add your handling code here:
    ResultSet rs = null;
        float cantidad=0,totalarticulos=0;
        int nobjetotabla=this.jtb_insumos.getRowCount();
        int fi=0,controlfolio=0,error=0;

        String cadenafilas="{'", arreglo_articulos[]=null;
        JPasswordField pwd = new JPasswordField(10);
        this.quitarfotosestereporte();
        //lanso la confirmacion de password
        int action = JOptionPane.showConfirmDialog(null, pwd,"Contraseña:(Use Tab p/moverse o Mause)",JOptionPane.OK_CANCEL_OPTION);
        if(action < 0) {
            JOptionPane.showMessageDialog(null,"No se realiza Proceso, Gracias");
        } else {
            //comparo si la contraseña es apropiada
            if(variables_global.getPassword().equals(String.valueOf(pwd.getPassword()))) {//inicia trabajo para actualizar diferencias

                for(fi=0;fi<nobjetotabla;fi++) {

                        try{
                            cantidad = Float.valueOf(this.jtb_insumos.getValueAt(fi, 4).toString()).floatValue();
                            totalarticulos+=cantidad;
                        }catch (NumberFormatException nfe) {
                            cantidad=0;
                            error=1;
                        }
                    // System.out.println("cachar error"+cadenafilas);
                    if (cantidad > 0)
                        {
                            cadenafilas+=""+this.jtb_insumos.getValueAt(fi, 4).toString()+":"+this.jtb_insumos.getValueAt(fi, 0).toString()+":"+this.jtb_insumos.getValueAt(fi, 4)+""+"\n";
                        }
                }//fin del for
                    //System.out.println(s);
                //arreglo_articulos=cadenafilas.split(":");
                if((error==0)&&(totalarticulos  > 0))
                   {
                        if(JOptionPane.showConfirmDialog(null, "Documento sera Guardado. Estan correcto sus Datos?")==0)
                            {
                            this.quitardescripcion();
                            java.util.Vector arreglodearticulos=this.jtable_modelo.getDataVector();
                            String articulos_papostgresql=arreglodearticulos.toString();
                            articulos_papostgresql=articulos_papostgresql.replace('[','{');
                            articulos_papostgresql=articulos_papostgresql.replace(']','}');
                            articulos_papostgresql=articulos_papostgresql.replace("null",".");
                            String texto="select * from x1distribucion_insumos_salidas_surtir("+Integer.valueOf(this.jtf_folio.getText().toString())+",'"+articulos_papostgresql+"')";
                            System.out.println(texto);
                                try {
                                    rs=x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
                                    while (rs.next())
                                        {
                                            controlfolio=rs.getInt(1);
                                            if (rs.getInt(1) > 0)
                                                {
                                                    JOptionPane.showMessageDialog(null,"Requisicion Correcta, Gracias", "Sistema Integral(Requisicion Insumos) : Confirmacion",1);
                                                    this.imprimir(0,1,controlfolio);
                                                }
                                            else
                                                {
                                                    JOptionPane.showMessageDialog(null," Error Verifique sus Cantidades", "Sistema Integral(requisicion Insumos) : Error",1);
                                                }
                                        }
                                    }catch(Exception e)
                                       {
                                            System.out.println(e.getMessage());
                                            JOptionPane.showMessageDialog(null," Recepcion Incorrecta ", "Sistema Integral(Requisicion Insumos) : Error",1);
                                       }
                            //this.btn_guardar.setVisible(false);
                        }//fin del if qu confirmo guardar diferencia
                    }//cierra el if si la
                else
                    {
                        JOptionPane.showMessageDialog(null,"por Favor verifique que las cantidadades y que sean solo numeros Use Observaciones para dar detalle");
                    }
            }//cierra el if del password
            else
                {
                    JOptionPane.showMessageDialog(null,"por Favor teclee su contraseña coreectamente, verifique mayusculas en teclado");
                }

        }

}//GEN-LAST:event_jbtn_guardarActionPerformed

    private void jmni_escapeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_escapeActionPerformed
        // TODO add your handling code here:
        this.jmni_salirActionPerformed(evt);
    }//GEN-LAST:event_jmni_escapeActionPerformed

    private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged
        // TODO add your handling code here:
        indexactual=this.jTabbedPane1.getSelectedIndex();

          if((indexactual==1)&&(yacarguecatalogo==0))
                {
                   yacarguecatalogo=1;
                  this.loadcomalmacenes();
                  controlcombo=1;
                  this.carga_datos_catalogo_insumos(0, 0, "", 0);
                }
    }//GEN-LAST:event_jTabbedPane1StateChanged

    private void jbtn_sustituirarticuloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_sustituirarticuloActionPerformed
        // TODO add your handling code here:
if((this.jtf_idarticuloactual.getText().length()> 0) &&(this.jtf_idinsumonuevo.getText().length()> 0))
         if(JOptionPane.showConfirmDialog(null, "Estan correcto sus Datos?")==0)
            {
                this.articulo_actualizacodigo(1, this.jtf_folio.getText(), this.jtf_idarticuloactual.getText().trim(),this.jtf_idinsumonuevo.getText().trim());
            }
         else
             {
             JOptionPane.showMessageDialog(null,"por Favor Seleccione el Articulo para Actualizar");
             }
        
}//GEN-LAST:event_jbtn_sustituirarticuloActionPerformed

    private void jbtn_cancelacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_cancelacionActionPerformed
        // TODO add your handling code here:
        if(JOptionPane.showConfirmDialog(null, "Desea Cancelar el Documento?")==0)
            {
                this.articulo_actualizacodigo(2, this.jtf_folio.getText(), "","");
            }
    }//GEN-LAST:event_jbtn_cancelacionActionPerformed

    private void jcmbx_almacenesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmbx_almacenesActionPerformed
            // TODO add your handling code here:
    if(controlcombo==1)
        {
        if(JOptionPane.showConfirmDialog(null, "Desea Cambiar Almacen al Documento?")==0)
            {
                String arreglo_alma[]=this.jcmbx_almacenes.getSelectedItem().toString().split(":");
                this.articulo_actualizacodigo(3, this.jtf_folio.getText(),arreglo_alma[0],"");
            }
        }
    }//GEN-LAST:event_jcmbx_almacenesActionPerformed

    private void jmni_imprimiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_imprimiActionPerformed
        // TODO add your handling code here:
        this.jbtn_imprimirActionPerformed(evt);
    }//GEN-LAST:event_jmni_imprimiActionPerformed
     private void jt_insumos_catalogoMouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
    }
    private void jtb_insumos1MouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
    }
    private void quitardescripcion()
    {
     int numerofilas=this.jtable_modelo.getRowCount();
    String punto="",comas="",imagen="";

             for(int i = 0 ;i < numerofilas; i++)
                {

                      comas=jtable_modelo.getValueAt(i, 1).toString().replace(",", "");
                      jtable_modelo.setValueAt(comas, i,1);

                      punto=jtable_modelo.getValueAt(i, 5)+".";
                      jtable_modelo.setValueAt(punto, i,5);

                      imagen=jtable_modelo.getValueAt(i, 6)+".";
                      jtable_modelo.setValueAt(imagen, i,6);
                }
    }
private void imprimir(int pag,float ptotal,int folio)
    {
     this.objimpresora=new insumos_salidas_imprimir();
     this.objimpresora.setOneItem_cadenas_a_imprimir("Requisicion Insumos");
     //this.objimpresora.setOneItem_cadenas_a_imprimir("Fecha:"+this.+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Fecha:"+this.jtf_fecha.getText()+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Folio Tienda:"+String.valueOf(folio)+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Status Documento:"+"Requisicion"+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Cliente o Tienda:"+this.jtf_departamento.getText()+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Consignado A:"+this.jtf_nombreconsignado.getText()+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Observaciones:"+this.jtf_observaciones.getText()+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("*");
     this.objimpresora.setOneItem_cadenas_a_imprimir("paginas:"+ pag + " de "+ptotal+"");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Responsalbe Almacen: ______________");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Empaco: ______________");
     this.objimpresora.setOneItem_cadenas_a_imprimir("Recibio: ______________");
     this.objimpresora.setOneItem_cadenas_a_imprimir("..");
     this.objimpresora.setOneItem_cadenas_a_imprimir("..");
     this.objimpresora.setOneItem_cadenas_a_imprimir("..");
     this.objimpresora.setOneItem_cadenas_a_imprimir("..");
     this.objimpresora.setOneItem_cadenas_a_imprimir("..");
     this.objimpresora.setOneItem_cadenas_a_imprimir("..");
     this.objimpresora.setOneItem_cadenas_a_imprimir("..");
     this.objimpresora.setOneItem_cadenas_a_imprimir("*");
     this.objimpresora.setObjeto_tabla(jtb_insumos);
     this.objimpresora.imprimir_all(1,pag);
    }

    private  void ayuda()
            {
                String punto1=" 1.-Detalle de Recepcion de Mercancia, cada opcion se autodescribe brevemente\n";
                String punto2=" 2.- Cada Boton tiene Una letra Resaltada el cual indica su metodo abreviado uselo si desea mayor rapides ( ejemplo Alt+a tendra ayuda automaticamente)\n";
                String punto3=" 3.- la opcion guardar esta activada para Recepcionar este documento Incluyendo Diferencias si no ingresa diferencias, el sistema guardara el documento como correcto\n";
                JOptionPane.showMessageDialog(null,punto1+punto2+punto3, "Sistema Integral(Detalle Recepcion) : Ayuda",1);
            }
    private void dioclickdet(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
        System.out.println("dio doble  click");
        int fila = jtb_insumos1.getSelectedRow();
        
        this.jtf_idarticuloactual.setText(jtb_insumos1.getValueAt(fila, 0).toString());
        
    }
    private void dioclick(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
        System.out.println("dio doble  click");
        int fila = jt_insumos_catalogo.getSelectedRow();

        this.jtf_idinsumonuevo.setText(jt_insumos_catalogo.getValueAt(fila, 2).toString());

    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                insumos_salidas_detalle dialog = new insumos_salidas_detalle(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JButton jbtn_cancelacion;
    private javax.swing.JButton jbtn_guardar;
    private javax.swing.JButton jbtn_helpayudame;
    private javax.swing.JButton jbtn_imprimir;
    private javax.swing.JButton jbtn_recepcionar;
    private javax.swing.JButton jbtn_salir;
    private javax.swing.JButton jbtn_sustituirarticulo;
    private javax.swing.JCheckBox jcb_verfotos;
    private javax.swing.JCheckBox jckbx_surtircompleto;
    private javax.swing.JComboBox jcmbx_almacenes;
    private javax.swing.JMenuItem jmni_escape;
    private javax.swing.JMenuItem jmni_imprimi;
    private javax.swing.JMenuItem jmni_salir;
    private javax.swing.JPanel jpn_cuerpo;
    private javax.swing.JTable jt_insumos_catalogo;
    private javax.swing.JTable jtb_insumos;
    private javax.swing.JTable jtb_insumos1;
    private javax.swing.JTextField jtf_almacen;
    private javax.swing.JTextField jtf_departamento;
    private javax.swing.JTextField jtf_fecha;
    private javax.swing.JTextField jtf_fechaenterado;
    private javax.swing.JTextField jtf_fecharecibido;
    private javax.swing.JTextField jtf_folio;
    private javax.swing.JTextField jtf_idarticuloactual;
    private javax.swing.JTextField jtf_idinsumonuevo;
    private javax.swing.JTextField jtf_nombreconsignado;
    private javax.swing.JTextField jtf_observaciones;
    private javax.swing.JTextField jtf_status;
    private javax.swing.JTextField jtf_total;
    // End of variables declaration//GEN-END:variables
private insumos_salidas_imprimir objimpresora;
}
